package com.chcit.mobile.mvp.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chcit.custom.view.notify.Badge;
import com.chcit.custom.view.notify.QBadgeView;
import com.chcit.mobile.R;
import com.chcit.mobile.mvp.model.entity.HomeItem;
import com.jess.arms.base.app.Quick;
import java.util.List;
import java.util.WeakHashMap;


/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class HomeAdapter extends BaseQuickAdapter<HomeItem, BaseViewHolder> {

    private final WeakHashMap<String,Badge> badges = new WeakHashMap<>();

    public HomeAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeItem item) {
        helper.setText(R.id.text, item.getTitle());
        helper.setImageResource(R.id.icon, item.getImageResource());
        RequestOptions options = new RequestOptions()
                .placeholder(item.getImageResource());
      /*  Glide.with(Quick.getApplicationContext())
                .load(item.getUrl())
                .apply(options)
                .into((ImageView) helper.getView(R.id.icon));*/

        Badge badge = new QBadgeView(mContext).bindTarget(helper.getView(R.id.item_home_show));
        badge.setBadgeTextSize(12, true);
        badges.put(item.getTitle(),badge);
    }

    public Badge getBadge(String position){
        return badges.get(position);
    }
}
